package com.lou.springboot.service.impl;

import com.lou.springboot.dao.AdminUser1Dao;
import com.lou.springboot.entity.AdminUser1;
import com.lou.springboot.service.AdminUser1Service;
import com.lou.springboot.utils.MD5Util;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Created by Guaguaerhao on 2020/7/9 23:26
 */

@Service
public class AdminUser1ServiceImpl implements AdminUser1Service {

    @Autowired
    private AdminUser1Dao adminUser1Dao;

    public AdminUser1 login(String userName, String password) {
        String passwordMd5 = MD5Util.MD5Encode(password, "UTF-8");
        return adminUser1Dao.login(userName, passwordMd5);
    }

    public AdminUser1 getUserDetailById(Integer loginUserId){
        return adminUser1Dao.getUserAdminById(loginUserId);
    }

    public boolean updatePassword(Integer loginUserId, String originalPassword, String newPassword) {
        String updatedPassword = MD5Util.MD5Encode(newPassword, "UTF-8");
        String oldPassword = MD5Util.MD5Encode(originalPassword, "UTF-8");
        return adminUser1Dao.updatePassword(loginUserId, oldPassword, updatedPassword);
    }

    public boolean updateName(Integer loginUserId, String loginUserName, String nickName) {
        return adminUser1Dao.updateName(loginUserId, loginUserName, nickName);
    }
}
